package org.example;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class Stream_Demo5 {
    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<Integer>();
        Collections.addAll(list,1,2,3,4,5,6);
        List<Integer> list1 = list.stream().filter(s -> s % 2 == 0)
                .collect(Collectors.toList());
        System.out.println(list1);
        System.out.println("=============1");
        ArrayList<String> list2 = new ArrayList<>();
        Collections.addAll(list2, "张三,23", "李四,24", "王五,25", "张六财,26", "张七望,27", "孙八,28");
        Map<String, Integer> list3 = list2.stream()
                .filter(s -> Integer.parseInt(s.split(",")[1]) >= 26)
                .collect(Collectors.toMap(s -> s.split(",")[0]
                        , s -> Integer.parseInt(s.split(",")[1])));
                 System.out.println(list3);
                 System.out.println("=============2");
    }
}
